<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>SoapFault constructor</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="soapfault.construct.html">SoapFault::__construct</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="soapfault.tostring.html">SoapFault::__toString</a></div>
 <div class="up"><a href="class.soapfault.html">SoapFault</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="soapfault.soapfault" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SoapFault::SoapFault</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.0.1)</p><p class="refpurpose"><span class="refname">SoapFault::SoapFault</span> &mdash; <span class="dc-title">SoapFault constructor</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-soapfault.soapfault-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>SoapFault::SoapFault</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$faultcode</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$faultstring</code></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$faultactor</code></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$detail</code></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$faultname</code></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$headerfault</code></span>
  ]]]] )</div>

  <p class="para rdfs-comment">
   This class is used to send SOAP fault responses from the PHP handler.
   <em><code class="parameter">faultcode</code></em>, <em><code class="parameter">faultstring</code></em>,
   <em><code class="parameter">faultactor</code></em> and <em><code class="parameter">detail</code></em> are
   standard elements of a SOAP Fault.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-soapfault.soapfault-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">faultcode</code></em></dt>

     <dd>

      <p class="para">
       The error code of the <a href="class.soapfault.html" class="classname">SoapFault</a>.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">faultstring</code></em></dt>

     <dd>

      <p class="para">
       The error message of the <a href="class.soapfault.html" class="classname">SoapFault</a>.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">faultactor</code></em></dt>

     <dd>

      <p class="para">
       A string identifying the actor that caused the error.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">detail</code></em></dt>

     <dd>

      <p class="para">
       More details about the cause of the error.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">faultname</code></em></dt>

     <dd>

      <p class="para">
       Can be used to select the proper fault encoding from WSDL.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">headerfault</code></em></dt>

     <dd>

      <p class="para">
       Can be used during SOAP header handling to report an error in the
       response header.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-soapfault.soapfault-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5212">
    <p><strong>Example #1 Some examples</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">test</span><span style="color: #007700">(</span><span style="color: #0000BB">$x</span><span style="color: #007700">)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;new&nbsp;</span><span style="color: #0000BB">SoapFault</span><span style="color: #007700">(</span><span style="color: #DD0000">"Server"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Some&nbsp;error&nbsp;message"</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">$server&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SoapServer</span><span style="color: #007700">(</span><span style="color: #0000BB">null</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #DD0000">'uri'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"http://test-uri/"</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">$server</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">addFunction</span><span style="color: #007700">(</span><span style="color: #DD0000">"test"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$server</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">handle</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
  <p class="para">
   It is possible to use PHP exception mechanism to throw SOAP Fault.
  </p>
  <p class="para">
   <div class="example" id="example-5213">
    <p><strong>Example #2 Some examples</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">test</span><span style="color: #007700">(</span><span style="color: #0000BB">$x</span><span style="color: #007700">)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;throw&nbsp;new&nbsp;</span><span style="color: #0000BB">SoapFault</span><span style="color: #007700">(</span><span style="color: #DD0000">"Server"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Some&nbsp;error&nbsp;message"</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">$server&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SoapServer</span><span style="color: #007700">(</span><span style="color: #0000BB">null</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #DD0000">'uri'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"http://test-uri/"</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">$server</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">addFunction</span><span style="color: #007700">(</span><span style="color: #DD0000">"test"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$server</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">handle</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-soapfault.soapfault-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="soapserver.fault.html" class="methodname" rel="rdfs-seeAlso">SoapServer::fault()</a> - Issue SoapServer fault indicating an error</span></li>
    <li class="member"><span class="function"><a href="function.is-soap-fault.html" class="function" rel="rdfs-seeAlso">is_soap_fault()</a> - Checks if a SOAP call has failed</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="soapfault.construct.html">SoapFault::__construct</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="soapfault.tostring.html">SoapFault::__toString</a></div>
 <div class="up"><a href="class.soapfault.html">SoapFault</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
